package com.lgz.dbcourse.mapper;

import com.lgz.dbcourse.dto.MovieSeatDTO;
import com.lgz.dbcourse.entity.MovieSeatEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @Author: LGZ
 * @Date: 2021/4/12 16:36
 * @Description:
 */
public interface MovieSeatMapper {

    /**
     * TODO
     * @Description 获取对应场次影片的座位信息(可以选购即不包括已被选的位子)
     * @Author lgz
     * @Date 2021/4/12 16:43
     * @param movieSeatEntity :
     * @return : com.lgz.dbcourse.dto.MovieSeatDTO[]
     */
    @Select("SELECT ms_id, seat_code " +
            "FROM movie_seat, seat " +
            "WHERE movie_seat.seat_id = seat.seat_id " +
            "AND movie_seat.schedule_id = #{movieSeatEntity.scheduleId} " +
            "AND movie_seat.audience_id IS NULL")
    MovieSeatDTO[] getSeat(@Param("movieSeatEntity")MovieSeatEntity movieSeatEntity);

    /**
     * TODO
     * @Description 选购座位
     * @Author lgz
     * @Date 2021/4/12 16:52
     * @param movieSeatEntity :
     * @return : void
     */
    @Update("UPDATE movie_seat SET audience_id = #{movieSeatEntity.audienceId} WHERE ms_id = #{movieSeatEntity.msId}")
    void updateSeat(@Param("movieSeatEntity")MovieSeatEntity movieSeatEntity);
}
